from typing import Optional, Any

import scrapy
from env import logger

class LuoguSpider(scrapy.Spider):
    name = "luogu"
    allowed_domains = ["www.luogu.com.cn"]
    base_url = "https://www.luogu.com.cn/"

    custom_settings = {
        'ITEM_PIPELINES': {'crawl.pipelines.LuoguPipeline': 400, },
    }

    def start_requests(self):
        match self.opt:
            case "race":
                url = self.base_url + "acm/contest/vip-index"
                logger.info(f"url:{url}")
                yield scrapy.Request(url, callback=self.race_parse)  # 指定回调函数,否则默认回调parse函数

    def race_parse(self, response):
        pass
